<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
    <meta name="generator" content="Jekyll v3.8.6">
    <title>登录</title>
    <link rel="stylesheet" href="${request.contextPath}/statics/bootstrap/css/bootstrap.min.css">
    <meta name="theme-color" content="#563d7c">
    <style>
        html,
        body {
            height: 100%;
        }

        body {
            display: -ms-flexbox;
            display: flex;
            -ms-flex-align: center;
            align-items: center;
            padding-top: 40px;
            padding-bottom: 40px;
            background-color: #f5f5f5;
        }

        .form-signin {
            width: 100%;
            max-width: 420px;
            padding: 15px;
            margin: auto;
        }

        .form-label-group {
            position: relative;
            margin-bottom: 1rem;
        }

        .form-label-group > input,
        .form-label-group > label {
            height: 3.125rem;
            padding: .75rem;
        }

        .form-label-group > label {
            position: absolute;
            top: 0;
            left: 0;
            display: block;
            width: 100%;
            margin-bottom: 0; /* Override default `<label>` margin */
            line-height: 1.5;
            color: #495057;
            pointer-events: none;
            cursor: text; /* Match the input under the label */
            border: 1px solid transparent;
            border-radius: .25rem;
            transition: all .1s ease-in-out;
        }

        .form-label-group input::-webkit-input-placeholder {
            color: transparent;
        }

        .form-label-group input:-ms-input-placeholder {
            color: transparent;
        }

        .form-label-group input::-ms-input-placeholder {
            color: transparent;
        }

        .form-label-group input::-moz-placeholder {
            color: transparent;
        }

        .form-label-group input::placeholder {
            color: transparent;
        }

        .form-label-group input:not(:placeholder-shown) {
            padding-top: 1.25rem;
            padding-bottom: .25rem;
        }

        .form-label-group input:not(:placeholder-shown) ~ label {
            padding-top: .25rem;
            padding-bottom: .25rem;
            font-size: 12px;
            color: #777;
        }

        /* Fallback for Edge
        -------------------------------------------------- */
        @supports (-ms-ime-align: auto) {
            .form-label-group > label {
                display: none;
            }
            .form-label-group input::-ms-input-placeholder {
                color: #777;
            }
        }

        /* Fallback for IE
        -------------------------------------------------- */
        @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
            .form-label-group > label {
                display: none;
            }
            .form-label-group input:-ms-input-placeholder {
                color: #777;
            }
        }
        .bd-placeholder-img {
            font-size: 1.125rem;
            text-anchor: middle;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }

        @media (min-width: 768px) {
            .bd-placeholder-img-lg {
                font-size: 3.5rem;
            }
        }
    </style>
</head>
<body>
<div class="form-signin">
    <div class="text-center mb-4">
        <img class="mb-4" src="${request.contextPath}/statics/img/bootstrap-solid.svg" alt="" width="72" height="72">
        <h1 class="h3 mb-3 font-weight-normal">登录避暑山庄</h1>
    </div>

    <div class="form-label-group">
        <input type="text" id="username" class="form-control" placeholder="请输入用户名" required autofocus>
        <label for="username">用户名</label>
    </div>

    <div class="form-label-group">
        <input type="password" id="password" class="form-control" onkeydown="if(event.keyCode==13) userLogin()" placeholder="请输入密码" required>
        <label for="password">密码</label>
    </div>

<!--    <div class="checkbox mb-3">-->
<!--        <label>-->
<!--            <input type="checkbox" value="remember-me"> Remember me-->
<!--        </label>-->
<!--    </div>-->
    <button class="btn btn-lg btn-primary btn-block" id="submit">登录</button>
    <a class="btn btn-lg btn-primary btn-block" href="${request.contextPath}/">首页</a>
    <p class="mt-5 mb-3 text-muted text-center">&copy;<a href="http://www.mind-warning.top"
                                                         target="_blank">皮蛋布丁</a> 2021-2031</p>
</div>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script src="${request.contextPath}/statics/bootstrap/js/bootstrap.min.js"></script>
<script async="" charset="utf-8" src="${request.contextPath}/statics/layer/layer.js"></script>
<script>
    $("#submit").click(function () {
        userLogin();
    });
    
    function userLogin() {
        var username = $("#username").val();
        var password = $("#password").val();
        $.post("sys/login",{username: username, password: password}, function (res) {
            if(res.code == 0){
                layer.msg("登录成功!");
                setTimeout(function () {
                    if(res.data.userType == 0){
                        window.location.href="${request.contextPath}/";
                    }else{
                        window.location.href="${request.contextPath}/index.html";
                    }
                },1000);

            }else{
                layer.msg(res.msg, {icon: 5});
            }
        })
    }
</script>
</body>
</html>
